<template>
    <!--    用来做精准的权限menu-->
    <div class="mIndex">
        <!--        <el-button class="el-button&#45;&#45;warning">ManagerIndex</el-button>-->
        <el-row>
            <el-col :span="20">
                <el-tag> 身 份 认 证 与 权 限 管 理</el-tag>
            </el-col>
            <el-col :span="4">
                <!--                <el-dropdown class="el-button&#45;&#45;warning">个人中心:</el-dropdown>-->

                <el-button type="warning" @click="logout">{{userDetail.nickname}} 登出 {{auth}}</el-button>
            </el-col>
        </el-row>
        <div class="el-container">
            <div class="el-aside" style="width: 20%;height:500px;background-color: paleturquoise">

                <!--            <router-link to="/consumer/download" >下载练习页面</router-link>-->
                <!--            <br/>-->
                <!--            <router-link to="/consumer/personAdd" >实体练习页面</router-link>-->

                <el-menu class="cMenu" router="true" :default-active="$route.path">
                    <!--                <el-submenu v-for="group in $router.options.routes"-->
                    <el-submenu class="cSubMenu" v-for="group in menuRoutes"
                                :key="group.path" :index="group.path">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <el-link :underline="false">{{group.description}}</el-link>
                            <!--                            <span></span>-->
                        </template>

                        <el-menu-item class="cMenuItem" v-for="i in group.children"
                                      :key="i.path" :index="i.path">
                            <i class="el-icon-document"></i>
                            <span slot="title">
                                 <el-link :underline="false">{{i.description}}</el-link>
                                </span>
                        </el-menu-item>
                    </el-submenu>
                </el-menu>

            </div>
            <router-view></router-view>
        </div>
    </div>
</template>

<script>
    // import New from './components/New.vue';
    import {managerRoutes} from '../router'
    import {mapState} from 'vuex'

    export default {

        name: "ManagerIndex",
        components: {
            // New,Old,
        },
        props: {
            sampleP: {
                type: Number,
                default: 0
            },
        },
        data() {
            return {
                sampleD: 'value',
                menuRoutes: [managerRoutes],
            }
        },
        computed: {
            ...mapState(['userDetail', 'auth'])
            /**userDetail: {
            username: 'zhangsan001',
            userId: '99',
            nickname: 'Jam',
            }*/
            // sampleC() {
            //     return this.sampleD+'--';
            // }
        },
        created() {


        },
        mounted() {
        },
        methods: {
            ...mapState['setAuth', 'setUserDetail'],
            sampleM() {

            },
            logout() {
                this.$http({
                    method: 'post',
                    url: '/logout',
                    // data: this.,
                }).then(res => {
                    this.$message.warning(JSON.stringify("登出成功"+res.status));
                    // this.setAuth(false);
                    this.$store.commit('setAuth', false);
                    this.$router.push('/login')
                    // throw new Error({data:"erroryo"});
                    // this.$message.warning(JSON.stringify("登出成功 ,就要结束了"+res.status+res.data))
                    // this.setUserDetail({
                    //
                    // })
                    //logout进度条
                    // this.$router.push('/login')

                    //this.total = res.data.total;
                    //this.newsResults = res.data.results;
                }).catch(res => {
                    this.$message.warning(JSON.stringify("？？？登出失败"+res.data));
                    // this.$message.warning(JSON.stringify(res.data))
                });
            }
        },
        watch: {
            // sampleC(newValue, oldValue) {
            //
            // }
        },
    }
</script>

<style scoped>
    /*<style lang='scss' scoped>*/
    .mIndex {
        background-color: rgba(255, 206, 41, 0.72);
    }
</style>